home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 5 / Apprentice-Release5.iso / Source Code / Think Class Libraries / WASTE TCL 2.0b2 / WASTE VA / Source / CApp.cp~ < prev    next >
Encoding:
Text File  |  1995-11-12  |  5.7 KB  |  219 lines  |  [TEXT/KAHL]

  1. /******************************************************************************
  2.  CApp.cp
  3.  
  4.                 My Application Class
  5.     
  6.     Copyright Â© 1995 Dan Crevier. All rights reserved.
  7.  
  8.     Generated by Visual Architectâ„¢ 9:19 AM Mon, Nov 6, 1995
  9.  
  10.     This file is only generated once. You can modify it by filling
  11.     in the placeholder methods and adding any new methods you wish.
  12.  
  13.     If you change the name of the application, a fresh version of this
  14.     file will be generated. If you have made any changes to the file
  15.     with the old name, you will have to copy those changes to the new
  16.     file by hand.
  17.  
  18.  ******************************************************************************/
  19.  
  20. #include "CApp.h"
  21.  
  22. #include <CDialog.h>
  23. #include <TCLForceReferences.h>
  24.  
  25. //#include "AppCommands.h"            // Remove comments if DoCommand overridden
  26.  
  27. #include "CWASTEText.h"
  28. #include "CWASTEDlgText.h"
  29.  
  30. #ifndef __SCRIPT__
  31. #include <Script.h>
  32. #endif
  33.  
  34. #include "CTSMSwitchboard.h"
  35. #include "CTSMDesktop.h"
  36.  
  37. #include <Drag.h>
  38.  
  39. static Boolean    DragAndDropAvailable(void);
  40. Boolean gHasDragAndDrop = false;
  41.  
  42. static Boolean    TSMAvailable(void);
  43.  
  44. extern CDesktop *gDesktop;
  45.  
  46. short gUsingTSM = false;
  47.  
  48. TCL_DEFINE_CLASS_M1(CApp, x_CApp);
  49.  
  50. /**** C O N S T R U C T I O N / D E S T R U C T I O N   M E T H O D S ****/
  51.  
  52. /******************************************************************************
  53.  CApp
  54.  
  55.         Constructor added by Dan Crevier
  56.  
  57.  ******************************************************************************/
  58.  
  59. CApp::CApp(void)
  60. {
  61.     gUsingTSM = TSMAvailable() && (InitTSMAwareApplication()==noErr);
  62.  
  63.     gHasDragAndDrop = DragAndDropAvailable();
  64.         
  65. }
  66.  
  67. /******************************************************************************
  68.  ICApp
  69.  
  70.         Initialize an Application.
  71.  
  72.  ******************************************************************************/
  73.  
  74. void    CApp::ICApp()
  75.  
  76. {
  77.         // The values below are:
  78.         //
  79.         //     extraMasters        - The number of additional master pointer blocks
  80.         //                          to be allocated.
  81.         //     aRainyDayFund        - The total amount of reserved memory. When
  82.         //                          allocation digs into the rainy day fund, the
  83.         //                          user is notified that memory is low. Set this
  84.         //                          value to the sum of aCriticalBalance plus
  85.         //                          aToolboxBalance plus a fudge for user warning.
  86.         //     aCriticalBalance    - The part of the rainy day fund reserved for
  87.         //                          critical operations, like Save or Quit. Set
  88.         //                          this value to the memory needed for the largest
  89.         //                          possible Save plus aToolboxBalance. This
  90.         //                          memory will only be used if SetCriticalOperation()
  91.         //                          is set TRUE or if RequestMemory()/SetAllocation()
  92.         //                          is set FALSE (kAllocCantFail).
  93.         //     aToolboxBalance    - The part of the rainy day fund reserved for
  94.         //                          ToolBox bozos that bomb if a memory request fails.
  95.         //                          This memory is used unless RequestMemory()/
  96.         //                          SetAllocation() is set TRUE (kAllocCanFail).
  97.         //                          Almost all TCL memory allocation is done with
  98.         //                          kAllocCanFail, and yours should be, too. The
  99.         //                          default 2K is probably enough.
  100.  
  101.     Ix_CApp(4, 24000L, 20480L, 2048L);
  102.     
  103.         // Initialize your own application data here.
  104.  
  105. }
  106.  
  107.  
  108. /******************************************************************************
  109.  ~CApp
  110.  
  111.         Destruct an Application.
  112.  
  113.  ******************************************************************************/
  114.  
  115. CApp::~CApp()
  116. {
  117.     if (gUsingTSM) CloseTSMAwareApplication();
  118. }
  119.  
  120. /******************************************************************************
  121.  ForceClassReferences    {OVERRIDE}
  122.  
  123.     Reference classes that do object I/O or are created only
  124.     by new_by_name.
  125.  ******************************************************************************/
  126.  
  127. void CApp::ForceClassReferences(void)
  128.  
  129. {
  130.     x_CApp::ForceClassReferences();
  131.     
  132.         // Insert your own class references here
  133.         // by calling TCL_FORCE_REFERENCE for each class
  134.         // See x_CApp.cp
  135.     
  136.     TCL_FORCE_REFERENCE(CWASTEText);
  137.     TCL_FORCE_REFERENCE(CWASTEDlgText);
  138.     
  139. }
  140.  
  141.  
  142. /**** C O M M A N D   M E T H O D S ****/
  143.  
  144.  
  145. /******************************************************************************
  146.  DoCommand    {OVERRIDE}
  147.  
  148.     Handle application commands
  149.  ******************************************************************************/
  150.  
  151. void CApp::DoCommand(long theCommand)
  152.  
  153. {
  154.     switch (theCommand)
  155.     {
  156.  
  157.             // Insert your command cases here
  158.  
  159.         default:
  160.             x_CApp::DoCommand(theCommand);
  161.             break;
  162.     }
  163. }
  164.  
  165.  
  166. /******************************************************************************
  167.  GetDocTypeFromDialog
  168.  
  169.     Get the document type from the dialog. If you have multiple
  170.     document types, you must override this function to extract
  171.     the type from the dialog state. (The dialog has been executed
  172.     and OK'd by the user.) If you do not have multiple document
  173.     types, you can remove this function.
  174.  ******************************************************************************/
  175.  
  176. OSType CApp::GetDocTypeFromDialog(CDialogDirector *dialog)
  177.  
  178. {
  179.     return 0;
  180. }
  181.  
  182. // make TSMSwitchboard
  183. void CApp::MakeSwitchboard( void)
  184. {
  185.     if (gSystem.hasAppleEvents && gUsingTSM)
  186.     {
  187.         FailOSErr(WEInstallTSMHandlers());
  188.     }
  189.     itsSwitchboard = (CSwitchboard *)new CTSMSwitchboard();
  190.     itsSwitchboard->InitAppleEvents();
  191. }
  192.  
  193. // make TSMDesktop
  194. void CApp::MakeDesktop(void)
  195. {
  196.     gDesktop = (CDesktop *)new CTSMDesktop();
  197. }
  198.  
  199. static Boolean TSMAvailable(void)
  200. {
  201.     long    response;
  202.     
  203.     return (Gestalt(gestaltTSMgrVersion, &response)==noErr);
  204. }
  205.  
  206. /******************************************************************************
  207.  DragAndDropAvailable - returns true if drag and drop is available
  208.  ******************************************************************************/
  209.  
  210. static Boolean DragAndDropAvailable(void)
  211. {
  212.     long response;
  213.  
  214.     if (Gestalt(gestaltDragMgrAttr, &response) != noErr) return false;
  215.     if ((response & (1 << gestaltDragMgrPresent)) == 0) return false;
  216.     if ((Ptr)InstallTrackingHandler == 0) return false;
  217.     return true;
  218. }
  219.